#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
int CountDigit(int number, int digit) {
	int arr[10] = { 0 };
	while (number) {
		if (number % 10 == digit) {
			arr[digit]++;
		}
		number /= 10;
	}
	return arr[digit];
}
int main()
{
	int number, digit;
	cin >> number >> digit;
	cout << CountDigit(number, digit);
	return 0;
}